<template>
  <div class="container">
    <CSuperForm v-bind="cSearch" v-on="methods.cSearch" />
    <Ctable v-bind="cTable" v-on="methods.cTable" />
    <CSuperForm v-bind="cDio" v-on="methods.cDio" />
  </div>
</template>
<script setup lang="ts">
import { intialFnFn, intialDataFn } from "@/components/CSuperForm/index";
let intialDataFnClass = new intialDataFn();
let cTableintialData: IntialDataType = {
  cTableOpt: {
    list: { url: "/admin/msImage" },
    delete: { url: "/admin/msImage" },
    columns: [
      { prop: "id", label: "ID" },
      { prop: "title", label: "图片标题" },
      { prop: "imgUrl", label: "图片", render: "img" },
      { prop: "location", label: "图片位置", render: "params", Object: { HomeTopBanner: "首页轮播图" } },
      { prop: "href", label: "跳转链接" },
      { prop: "orderNo", label: "排列序号" },
      { prop: "addTime", label: "添加时间", render: "timeStamp" },
      { prop: "updateTime", label: "更新时间", render: "timeStamp" }
    ]
  }
};
let cTable = ref(intialDataFnClass.add(cTableintialData, "cTable"));
let cDiointialData: IntialDataType = {
  cformOpt: {
    saveUrl: "/admin/msImage",
    items: {
      title: { label: "图片标题", type: "input", hasrules: true },
      imgUrl: { label: "图片", type: "uImg", hasrules: true },
      location: { label: "位置", type: "select", values: [{ id: "HomeTopBanner", name: "首页轮播图" }], hasrules: true },
      href: { label: "跳转链接", type: "input" },
      orderNo: { label: "排列序号", type: "input" }
    }
  }
};
let cDio = ref(intialDataFnClass.add(cDiointialData, "cDio"));
let cSearchintialData: IntialDataType = {
  cformOpt: {
    items: {
      id: { label: "ID", type: "input" }
    }
  }
};
let cSearch = ref(intialDataFnClass.add(cSearchintialData, "cSearch"));
let intialFn: intialFnType = {
  cSearch: {
    commonFn: [
      { methodName: "showAdd", other: { refKey: "cDio" } },
      { methodName: "getListFn", other: { refKey: "cTable", cSearchKey: "cSearch" } }
    ]
  },
  cTable: { commonFn: [{ methodName: "showAdd", other: { refKey: "cDio" } }] },
  cDio: { commonFn: [{ methodName: "getListFn", other: { refKey: "cTable" } }] }
};
let methods: any = ref({ cSearch: {}, cTable: {}, cDio: {} });
onMounted(() => {
  methods.value = intialFnFn({ obj: intialDataFnClass.obj, intialFn });
});
</script>
